﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;

namespace RemoteClient.UI
{
    public partial class RemoteFileItem : ListViewItem
    {
        private RemoteObject.DownloadJob dJob;
        private ListViewSubItem nameItem;
        private ListViewSubItem sizeItem;
        private ListViewSubItem urlItem;

        public RemoteObject.DownloadJob DJob
        {
            get 
            {
                return dJob;
            }
            set
            {
                dJob = value;
                InitSubItems();
            }
        }

        public RemoteFileItem(RemoteObject.DownloadJob dJob)
        {
            this.dJob = dJob;
            InitSubItems();
        }

        private void InitSubItems()
        {
            nameItem = new ListViewSubItem(this, dJob.GetJobName());
            sizeItem = new ListViewSubItem(this, dJob.GetStatus() == RemoteObject.Common.Status.Completed ? "On Cloud" : "On Site");
            urlItem = new ListViewSubItem(this, dJob.GetServerURL().ToString());
            
            SubItems.Clear();
            SubItems.Insert(0, nameItem);
            SubItems.Insert(1, sizeItem);
            SubItems.Insert(2, urlItem);            
        }
    }
}
